﻿using System;
using System.Collections.Generic;
using Helpers;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.CharacterDevelopment;
using TaleWorlds.CampaignSystem.Conversation;
using TaleWorlds.CampaignSystem.Extensions;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Roster;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.Issues
{
	// Token: 0x02000304 RID: 772
	public class GangLeaderNeedsRecruitsIssueBehavior : CampaignBehaviorBase
	{
		// Token: 0x06002D07 RID: 11527 RVA: 0x000BCBFC File Offset: 0x000BADFC
		public override void RegisterEvents()
		{
			CampaignEvents.OnCheckForIssueEvent.AddNonSerializedListener(this, new Action<Hero>(this.OnCheckForIssue));
		}

		// Token: 0x06002D08 RID: 11528 RVA: 0x000BCC15 File Offset: 0x000BAE15
		public override void SyncData(IDataStore dataStore)
		{
		}

		// Token: 0x06002D09 RID: 11529 RVA: 0x000BCC17 File Offset: 0x000BAE17
		private static bool ConditionsHold(Hero issueGiver)
		{
			return issueGiver.CurrentSettlement != null && issueGiver.IsGangLeader;
		}

		// Token: 0x06002D0A RID: 11530 RVA: 0x000BCC2C File Offset: 0x000BAE2C
		public void OnCheckForIssue(Hero hero)
		{
			if (GangLeaderNeedsRecruitsIssueBehavior.ConditionsHold(hero))
			{
				Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(new PotentialIssueData.StartIssueDelegate(GangLeaderNeedsRecruitsIssueBehavior.OnSelected), typeof(GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssue), IssueBase.IssueFrequency.VeryCommon, null));
				return;
			}
			Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(typeof(GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssue), IssueBase.IssueFrequency.VeryCommon));
		}

		// Token: 0x06002D0B RID: 11531 RVA: 0x000BCC8F File Offset: 0x000BAE8F
		private static IssueBase OnSelected(in PotentialIssueData pid, Hero issueOwner)
		{
			return new GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssue(issueOwner);
		}

		// Token: 0x04000D7F RID: 3455
		private const IssueBase.IssueFrequency GangLeaderNeedsRecruitsIssueFrequency = IssueBase.IssueFrequency.VeryCommon;

		// Token: 0x0200061C RID: 1564
		public class GangLeaderNeedsRecruitsIssue : IssueBase
		{
			// Token: 0x06004AF9 RID: 19193 RVA: 0x0015A1DE File Offset: 0x001583DE
			internal static void AutoGeneratedStaticCollectObjectsGangLeaderNeedsRecruitsIssue(object o, List<object> collectedObjects)
			{
				((GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssue)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06004AFA RID: 19194 RVA: 0x0015A1EC File Offset: 0x001583EC
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x17000F13 RID: 3859
			// (get) Token: 0x06004AFB RID: 19195 RVA: 0x0015A1F5 File Offset: 0x001583F5
			public override IssueBase.AlternativeSolutionScaleFlag AlternativeSolutionScaleFlags
			{
				get
				{
					return IssueBase.AlternativeSolutionScaleFlag.RequiredTroops;
				}
			}

			// Token: 0x17000F14 RID: 3860
			// (get) Token: 0x06004AFC RID: 19196 RVA: 0x0015A1F8 File Offset: 0x001583F8
			private int RequestedRecruitCount
			{
				get
				{
					return 6 + MathF.Ceiling(10f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17000F15 RID: 3861
			// (get) Token: 0x06004AFD RID: 19197 RVA: 0x0015A20D File Offset: 0x0015840D
			public override int AlternativeSolutionBaseNeededMenCount
			{
				get
				{
					return 11 + MathF.Ceiling(9f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17000F16 RID: 3862
			// (get) Token: 0x06004AFE RID: 19198 RVA: 0x0015A223 File Offset: 0x00158423
			protected override int AlternativeSolutionBaseDurationInDaysInternal
			{
				get
				{
					return 6 + MathF.Ceiling(7f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x17000F17 RID: 3863
			// (get) Token: 0x06004AFF RID: 19199 RVA: 0x0015A238 File Offset: 0x00158438
			protected override int RewardGold
			{
				get
				{
					return 2000 + this.RequestedRecruitCount * 100;
				}
			}

			// Token: 0x17000F18 RID: 3864
			// (get) Token: 0x06004B00 RID: 19200 RVA: 0x0015A249 File Offset: 0x00158449
			public override TextObject IssueBriefByIssueGiver
			{
				get
				{
					return new TextObject("{=YxtiyxSf}Yes... As you no doubt know, this is rough work, and I've lost a lot of good lads recently. I haven't had much luck replacing them. I need men who understand how things work in our business, and that's not always easy to find. I could use bandits and looters. They usually know their stuff. But if I take them in as prisoners, they'll just slip away as soon as I get the chance. I need volunteers...[ib:hip][if:convo_undecided_closed]", null);
				}
			}

			// Token: 0x17000F19 RID: 3865
			// (get) Token: 0x06004B01 RID: 19201 RVA: 0x0015A256 File Offset: 0x00158456
			public override TextObject IssueAcceptByPlayer
			{
				get
				{
					return new TextObject("{=jGpBZDvC}I see. What do you want from me?", null);
				}
			}

			// Token: 0x17000F1A RID: 3866
			// (get) Token: 0x06004B02 RID: 19202 RVA: 0x0015A263 File Offset: 0x00158463
			public override TextObject IssueQuestSolutionExplanationByIssueGiver
			{
				get
				{
					return new TextObject("{=Qh26ReAv}Look, I know that warriors like you can sometimes recruit bandits to your party. Some of those men might want to take their chances working for me. More comfortable in living in town, where there's always drink and women on hand, then roaming endlessly about the countryside, eh? For each one that signs up with me I'll give you a bounty, more if they have some experience.[if:convo_innocent_smile][ib:hip]", null);
				}
			}

			// Token: 0x17000F1B RID: 3867
			// (get) Token: 0x06004B03 RID: 19203 RVA: 0x0015A270 File Offset: 0x00158470
			public override TextObject IssueQuestSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=ekLDmgS7}I'll find your recruits.", null);
				}
			}

			// Token: 0x17000F1C RID: 3868
			// (get) Token: 0x06004B04 RID: 19204 RVA: 0x0015A27D File Offset: 0x0015847D
			public override TextObject IssueAlternativeSolutionExplanationByIssueGiver
			{
				get
				{
					return new TextObject("{=bKfaMFVK}You can also send me a recruiter: a trustworthy companion who is good at leading men, and also enough of a rogue to win the trust of other rogues...[if:convo_undecided_open][ib:confident]", null);
				}
			}

			// Token: 0x17000F1D RID: 3869
			// (get) Token: 0x06004B05 RID: 19205 RVA: 0x0015A28A File Offset: 0x0015848A
			public override TextObject IssueAlternativeSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=kxvnA811}All right, I will send you someone from my party who fits your bill.", null);
				}
			}

			// Token: 0x17000F1E RID: 3870
			// (get) Token: 0x06004B06 RID: 19206 RVA: 0x0015A297 File Offset: 0x00158497
			public override TextObject IssueAlternativeSolutionResponseByIssueGiver
			{
				get
				{
					return new TextObject("{=8sDjwsnW}I'm sure your lieutenant will solve my problem. Thank you for your help.[if:convo_nonchalant][ib:demure2]", null);
				}
			}

			// Token: 0x17000F1F RID: 3871
			// (get) Token: 0x06004B07 RID: 19207 RVA: 0x0015A2A4 File Offset: 0x001584A4
			public override TextObject IssueDiscussAlternativeSolution
			{
				get
				{
					return new TextObject("{=TkvsBd4H}Your companion seems to have a knack with the local never-do-wells. I hear a lot of fine lads have already signed up.[if:convo_relaxed_happy][ib:hip2]", null);
				}
			}

			// Token: 0x17000F20 RID: 3872
			// (get) Token: 0x06004B08 RID: 19208 RVA: 0x0015A2B1 File Offset: 0x001584B1
			public override bool IsThereAlternativeSolution
			{
				get
				{
					return true;
				}
			}

			// Token: 0x17000F21 RID: 3873
			// (get) Token: 0x06004B09 RID: 19209 RVA: 0x0015A2B4 File Offset: 0x001584B4
			public override bool IsThereLordSolution
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17000F22 RID: 3874
			// (get) Token: 0x06004B0A RID: 19210 RVA: 0x0015A2B8 File Offset: 0x001584B8
			protected override TextObject AlternativeSolutionStartLog
			{
				get
				{
					TextObject textObject = new TextObject("{=wX14wxqF}You asked {COMPANION.LINK} to deliver at least {WANTED_RECRUIT_AMOUNT} looters and bandits to {ISSUE_GIVER.LINK} in {SETTLEMENT}. They should rejoin your party in {RETURN_DAYS} days.", null);
					textObject.SetCharacterProperties("ISSUE_GIVER", base.IssueOwner.CharacterObject, false);
					textObject.SetCharacterProperties("COMPANION", base.AlternativeSolutionHero.CharacterObject, false);
					textObject.SetTextVariable("WANTED_RECRUIT_AMOUNT", this.RequestedRecruitCount);
					textObject.SetTextVariable("SETTLEMENT", base.IssueOwner.CurrentSettlement.EncyclopediaLinkWithName);
					textObject.SetTextVariable("RETURN_DAYS", base.GetTotalAlternativeSolutionDurationInDays());
					return textObject;
				}
			}

			// Token: 0x17000F23 RID: 3875
			// (get) Token: 0x06004B0B RID: 19211 RVA: 0x0015A33E File Offset: 0x0015853E
			public override TextObject Title
			{
				get
				{
					return new TextObject("{=rrh7rSLs}Gang Needs Recruits", null);
				}
			}

			// Token: 0x17000F24 RID: 3876
			// (get) Token: 0x06004B0C RID: 19212 RVA: 0x0015A34B File Offset: 0x0015854B
			public override TextObject Description
			{
				get
				{
					TextObject textObject = new TextObject("{=0kYaAb7c}A gang leader needs recruits for {?ISSUE_GIVER.GENDER}her{?}his{\\?} gang.", null);
					textObject.SetCharacterProperties("ISSUE_GIVER", base.IssueOwner.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x06004B0D RID: 19213 RVA: 0x0015A36F File Offset: 0x0015856F
			public GangLeaderNeedsRecruitsIssue(Hero issueOwner) : base(issueOwner, CampaignTime.DaysFromNow(30f))
			{
			}

			// Token: 0x06004B0E RID: 19214 RVA: 0x0015A382 File Offset: 0x00158582
			protected override float GetIssueEffectAmountInternal(IssueEffect issueEffect)
			{
				if (issueEffect == DefaultIssueEffects.IssueOwnerPower)
				{
					return -0.1f;
				}
				return 0f;
			}

			// Token: 0x06004B0F RID: 19215 RVA: 0x0015A397 File Offset: 0x00158597
			public override ValueTuple<SkillObject, int> GetAlternativeSolutionSkill(Hero hero)
			{
				return new ValueTuple<SkillObject, int>((hero.GetSkillValue(DefaultSkills.Leadership) >= hero.GetSkillValue(DefaultSkills.Roguery)) ? DefaultSkills.Leadership : DefaultSkills.Roguery, 120);
			}

			// Token: 0x06004B10 RID: 19216 RVA: 0x0015A3C4 File Offset: 0x001585C4
			public override bool DoTroopsSatisfyAlternativeSolution(TroopRoster troopRoster, out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(troopRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false);
			}

			// Token: 0x06004B11 RID: 19217 RVA: 0x0015A3DC File Offset: 0x001585DC
			public override bool AlternativeSolutionCondition(out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(MobileParty.MainParty.MemberRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false);
			}

			// Token: 0x06004B12 RID: 19218 RVA: 0x0015A3FD File Offset: 0x001585FD
			public override bool IsTroopTypeNeededByAlternativeSolution(CharacterObject character)
			{
				return character.Tier >= 2;
			}

			// Token: 0x06004B13 RID: 19219 RVA: 0x0015A40B File Offset: 0x0015860B
			protected override void OnGameLoad()
			{
			}

			// Token: 0x06004B14 RID: 19220 RVA: 0x0015A40D File Offset: 0x0015860D
			protected override void HourlyTick()
			{
			}

			// Token: 0x06004B15 RID: 19221 RVA: 0x0015A40F File Offset: 0x0015860F
			protected override QuestBase GenerateIssueQuest(string questId)
			{
				return new GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssueQuest(questId, base.IssueOwner, CampaignTime.DaysFromNow(30f), this.RequestedRecruitCount);
			}

			// Token: 0x06004B16 RID: 19222 RVA: 0x0015A42D File Offset: 0x0015862D
			public override IssueBase.IssueFrequency GetFrequency()
			{
				return IssueBase.IssueFrequency.VeryCommon;
			}

			// Token: 0x06004B17 RID: 19223 RVA: 0x0015A430 File Offset: 0x00158630
			protected override bool CanPlayerTakeQuestConditions(Hero issueGiver, out IssueBase.PreconditionFlags flag, out Hero relationHero, out SkillObject skill)
			{
				flag = IssueBase.PreconditionFlags.None;
				relationHero = null;
				skill = null;
				if (issueGiver.GetRelationWithPlayer() < -10f)
				{
					flag |= IssueBase.PreconditionFlags.Relation;
					relationHero = issueGiver;
				}
				return flag == IssueBase.PreconditionFlags.None;
			}

			// Token: 0x06004B18 RID: 19224 RVA: 0x0015A457 File Offset: 0x00158657
			public override bool IssueStayAliveConditions()
			{
				return true;
			}

			// Token: 0x06004B19 RID: 19225 RVA: 0x0015A45A File Offset: 0x0015865A
			protected override void CompleteIssueWithTimedOutConsequences()
			{
			}

			// Token: 0x17000F25 RID: 3877
			// (get) Token: 0x06004B1A RID: 19226 RVA: 0x0015A45C File Offset: 0x0015865C
			protected override int CompanionSkillRewardXP
			{
				get
				{
					return (int)(500f + 700f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x06004B1B RID: 19227 RVA: 0x0015A471 File Offset: 0x00158671
			protected override void AlternativeSolutionEndWithSuccessConsequence()
			{
				TraitLevelingHelper.OnIssueSolvedThroughQuest(base.IssueOwner, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Honor, 30)
				});
				base.IssueOwner.AddPower(10f);
				this.RelationshipChangeWithIssueOwner = 5;
			}

			// Token: 0x0400196C RID: 6508
			private const int IssueAndQuestDuration = 30;

			// Token: 0x0400196D RID: 6509
			private const int AlternativeSolutionTroopTierRequirement = 2;

			// Token: 0x0400196E RID: 6510
			private const int AlternativeSolutionRelationBonus = 5;

			// Token: 0x0400196F RID: 6511
			private const int AlternativeSolutionNotablePowerBonus = 10;

			// Token: 0x04001970 RID: 6512
			private const int AlternativeSolutionPlayerHonorBonus = 30;

			// Token: 0x04001971 RID: 6513
			private const int AlternativeSolutionRewardPerRecruit = 100;

			// Token: 0x04001972 RID: 6514
			private const int CompanionRequiredSkillLevel = 120;
		}

		// Token: 0x0200061D RID: 1565
		public class GangLeaderNeedsRecruitsIssueQuest : QuestBase
		{
			// Token: 0x06004B1C RID: 19228 RVA: 0x0015A4AA File Offset: 0x001586AA
			internal static void AutoGeneratedStaticCollectObjectsGangLeaderNeedsRecruitsIssueQuest(object o, List<object> collectedObjects)
			{
				((GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssueQuest)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06004B1D RID: 19229 RVA: 0x0015A4B8 File Offset: 0x001586B8
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
				collectedObjects.Add(this._questProgressLogTest);
			}

			// Token: 0x06004B1E RID: 19230 RVA: 0x0015A4CD File Offset: 0x001586CD
			internal static object AutoGeneratedGetMemberValue_requestedRecruitCount(object o)
			{
				return ((GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssueQuest)o)._requestedRecruitCount;
			}

			// Token: 0x06004B1F RID: 19231 RVA: 0x0015A4DF File Offset: 0x001586DF
			internal static object AutoGeneratedGetMemberValue_deliveredRecruitCount(object o)
			{
				return ((GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssueQuest)o)._deliveredRecruitCount;
			}

			// Token: 0x06004B20 RID: 19232 RVA: 0x0015A4F1 File Offset: 0x001586F1
			internal static object AutoGeneratedGetMemberValue_rewardGold(object o)
			{
				return ((GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssueQuest)o)._rewardGold;
			}

			// Token: 0x06004B21 RID: 19233 RVA: 0x0015A503 File Offset: 0x00158703
			internal static object AutoGeneratedGetMemberValue_playerReachedRequestedAmount(object o)
			{
				return ((GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssueQuest)o)._playerReachedRequestedAmount;
			}

			// Token: 0x06004B22 RID: 19234 RVA: 0x0015A515 File Offset: 0x00158715
			internal static object AutoGeneratedGetMemberValue_questProgressLogTest(object o)
			{
				return ((GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssueQuest)o)._questProgressLogTest;
			}

			// Token: 0x17000F26 RID: 3878
			// (get) Token: 0x06004B23 RID: 19235 RVA: 0x0015A522 File Offset: 0x00158722
			public override TextObject Title
			{
				get
				{
					return new TextObject("{=rrh7rSLs}Gang Needs Recruits", null);
				}
			}

			// Token: 0x17000F27 RID: 3879
			// (get) Token: 0x06004B24 RID: 19236 RVA: 0x0015A52F File Offset: 0x0015872F
			public override bool IsRemainingTimeHidden
			{
				get
				{
					return false;
				}
			}

			// Token: 0x17000F28 RID: 3880
			// (get) Token: 0x06004B25 RID: 19237 RVA: 0x0015A534 File Offset: 0x00158734
			private TextObject QuestStartedLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=PZI9Smv3}{QUEST_GIVER.LINK}, a gang leader in {SETTLEMENT}, told you that {?QUEST_GIVER.GENDER}she{?}he{\\?} needs recruits for {?QUEST_GIVER.GENDER}her{?}his{\\?} gang. {?QUEST_GIVER.GENDER}She{?}He{\\?} asked you to recruit {NEEDED_RECRUIT_AMOUNT} looters or bandits into your party, then transfer them to {?QUEST_GIVER.GENDER}her{?}him{\\?}. You will be paid for the recruits depending on their experience.", null);
					textObject.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
					textObject.SetTextVariable("SETTLEMENT", base.QuestGiver.CurrentSettlement.EncyclopediaLinkWithName);
					textObject.SetTextVariable("NEEDED_RECRUIT_AMOUNT", this._requestedRecruitCount);
					return textObject;
				}
			}

			// Token: 0x17000F29 RID: 3881
			// (get) Token: 0x06004B26 RID: 19238 RVA: 0x0015A591 File Offset: 0x00158791
			private TextObject QuestSuccessLog
			{
				get
				{
					TextObject textObject = new TextObject("{=3ApJ6LaX}You have transferred the recruits to {QUEST_GIVER.LINK} as promised.", null);
					textObject.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x17000F2A RID: 3882
			// (get) Token: 0x06004B27 RID: 19239 RVA: 0x0015A5B5 File Offset: 0x001587B5
			private TextObject QuestFailedWithTimeOutLogText
			{
				get
				{
					TextObject textObject = new TextObject("{=iUmWTmQz}You have failed to deliver enough recruits in time. {QUEST_GIVER.LINK} must be disappointed.", null);
					textObject.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x06004B28 RID: 19240 RVA: 0x0015A5D9 File Offset: 0x001587D9
			public GangLeaderNeedsRecruitsIssueQuest(string questId, Hero questGiver, CampaignTime duration, int requestedRecruitCount) : base(questId, questGiver, duration, 0)
			{
				this._requestedRecruitCount = requestedRecruitCount;
				this._deliveredRecruitCount = 0;
				this._rewardGold = 2000;
				this._playerReachedRequestedAmount = false;
				this.SetDialogs();
				base.InitializeQuestOnCreation();
			}

			// Token: 0x06004B29 RID: 19241 RVA: 0x0015A614 File Offset: 0x00158814
			private void QuestAcceptedConsequences()
			{
				base.StartQuest();
				base.AddTrackedObject(base.QuestGiver.CurrentSettlement);
				this._questProgressLogTest = base.AddDiscreteLog(this.QuestStartedLogText, new TextObject("{=r8rwl9ZS}Delivered Recruits", null), this._deliveredRecruitCount, this._requestedRecruitCount, null, false);
			}

			// Token: 0x06004B2A RID: 19242 RVA: 0x0015A664 File Offset: 0x00158864
			protected override void SetDialogs()
			{
				this.OfferDialogFlow = DialogFlow.CreateDialogFlow("issue_classic_quest_start", 100).NpcLine(new TextObject("{=0QuAZ8YO}I'll be waiting. Good luck.[if:convo_relaxed_happy][ib:confident]", null), null, null).Condition(() => Hero.OneToOneConversationHero == this.QuestGiver).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestAcceptedConsequences)).CloseDialog();
				TextObject npcDiscussLine = new TextObject("{=!}{GANG_LEADER_NEEDS_RECRUITS_QUEST_NOTABLE_DISCUSS}", null);
				TextObject npcResponseLine = new TextObject("{=!}{GANG_LEADER_NEEDS_RECRUITS_QUEST_NOTABLE_RESPONSE}", null);
				bool changeDialogAfterTransfer = false;
				this.DiscussDialogFlow = DialogFlow.CreateDialogFlow("quest_discuss", 100).BeginNpcOptions().NpcOption(new TextObject("{=BGgDjRcW}I think that's enough. Here is your payment.", null), () => Hero.OneToOneConversationHero == this.QuestGiver && this._playerReachedRequestedAmount, null, null).Consequence(delegate
				{
					this.ApplyQuestSuccessConsequences();
					this.CompleteQuestWithSuccess();
				}).CloseDialog().NpcOption(npcDiscussLine, delegate()
				{
					if (Hero.OneToOneConversationHero != this.QuestGiver)
					{
						return false;
					}
					if (!changeDialogAfterTransfer)
					{
						npcDiscussLine.SetTextVariable("GANG_LEADER_NEEDS_RECRUITS_QUEST_NOTABLE_DISCUSS", new TextObject("{=1hpeeCJD}Have you found any good men?[ib:confident3]", null));
						changeDialogAfterTransfer = true;
					}
					else
					{
						npcDiscussLine.SetTextVariable("GANG_LEADER_NEEDS_RECRUITS_QUEST_NOTABLE_DISCUSS", new TextObject("{=ds294zxi}Anything else?", null));
						changeDialogAfterTransfer = false;
					}
					return true;
				}, null, null).BeginPlayerOptions().PlayerOption(new TextObject("{=QbaOoilS}Yes, I have brought you a few men.", null), null).Condition(() => (this.CheckIfThereIsSuitableRecruitInPlayer() && !this._playerReachedRequestedAmount) & changeDialogAfterTransfer).NpcLine(npcResponseLine, null, null).Condition(delegate
				{
					if (this._playerReachedRequestedAmount)
					{
						return false;
					}
					npcResponseLine.SetTextVariable("GANG_LEADER_NEEDS_RECRUITS_QUEST_NOTABLE_RESPONSE", new TextObject("{=70LnOZzo}Very good. Keep searching. We still need more men.[ib:hip2]", null));
					return true;
				}).Consequence(new ConversationSentence.OnConsequenceDelegate(this.OpenRecruitDeliveryScreen)).PlayerLine(new TextObject("{=IULW8h03}Sure.", null), null).Consequence(delegate
				{
					if (this._playerReachedRequestedAmount && Campaign.Current.ConversationManager.IsConversationInProgress)
					{
						Campaign.Current.ConversationManager.ContinueConversation();
					}
				}).GotoDialogState("quest_discuss").PlayerOption(new TextObject("{=PZqGagXt}No, not yet. I'm still looking for them.", null), null).Condition(() => !this._playerReachedRequestedAmount & changeDialogAfterTransfer).Consequence(delegate
				{
					changeDialogAfterTransfer = false;
				}).NpcLine(new TextObject("{=L1JyetPq}I am glad to hear that.[ib:closed2]", null), null, null).CloseDialog().PlayerOption(new TextObject("{=OlOhuO7X}No thank you. Good day to you.", null), null).Condition(() => !this._playerReachedRequestedAmount && !changeDialogAfterTransfer).CloseDialog().EndPlayerOptions().CloseDialog().EndNpcOptions();
			}

			// Token: 0x06004B2B RID: 19243 RVA: 0x0015A858 File Offset: 0x00158A58
			private void OpenRecruitDeliveryScreen()
			{
				PartyScreenManager.OpenScreenWithCondition(new IsTroopTransferableDelegate(this.IsTroopTransferable), new PartyPresentationDoneButtonConditionDelegate(this.DoneButtonCondition), new PartyPresentationDoneButtonDelegate(this.DoneClicked), null, PartyScreenLogic.TransferState.Transferable, PartyScreenLogic.TransferState.NotTransferable, base.QuestGiver.Name, this._requestedRecruitCount - this._deliveredRecruitCount, false, false, PartyScreenMode.TroopsManage, null, null);
			}

			// Token: 0x06004B2C RID: 19244 RVA: 0x0015A8B0 File Offset: 0x00158AB0
			private Tuple<bool, TextObject> DoneButtonCondition(TroopRoster leftMemberRoster, TroopRoster leftPrisonRoster, TroopRoster rightMemberRoster, TroopRoster rightPrisonRoster, int leftLimitNum, int rightLimitNum)
			{
				if (this._requestedRecruitCount - this._deliveredRecruitCount < leftMemberRoster.TotalManCount)
				{
					int num = this._requestedRecruitCount - this._deliveredRecruitCount;
					TextObject textObject = new TextObject("{=VOr3uoRZ}You can only transfer {X} recruit{?IS_PLURAL}s{?}{\\?}.", null);
					textObject.SetTextVariable("IS_PLURAL", (num > 1) ? 1 : 0);
					textObject.SetTextVariable("X", num);
					return new Tuple<bool, TextObject>(false, textObject);
				}
				return new Tuple<bool, TextObject>(true, null);
			}

			// Token: 0x06004B2D RID: 19245 RVA: 0x0015A91C File Offset: 0x00158B1C
			private bool DoneClicked(TroopRoster leftMemberRoster, TroopRoster leftPrisonRoster, TroopRoster rightMemberRoster, TroopRoster rightPrisonRoster, FlattenedTroopRoster takenPrisonerRoster, FlattenedTroopRoster releasedPrisonerRoster, bool isForced, PartyBase leftParty, PartyBase rightParty)
			{
				foreach (TroopRosterElement troopRosterElement in leftMemberRoster.GetTroopRoster())
				{
					this._rewardGold += this.RewardForEachRecruit(troopRosterElement.Character) * troopRosterElement.Number;
					this._deliveredRecruitCount += troopRosterElement.Number;
				}
				this._questProgressLogTest.UpdateCurrentProgress(this._deliveredRecruitCount);
				this._questProgressLogTest.TaskName.SetTextVariable("TOTAL_REWARD", this._rewardGold);
				if (this._deliveredRecruitCount == this._requestedRecruitCount)
				{
					this._playerReachedRequestedAmount = true;
					if (Campaign.Current.ConversationManager.IsConversationInProgress)
					{
						Campaign.Current.ConversationManager.ContinueConversation();
					}
				}
				return true;
			}

			// Token: 0x06004B2E RID: 19246 RVA: 0x0015AA00 File Offset: 0x00158C00
			private int RewardForEachRecruit(CharacterObject recruit)
			{
				return (int)(100f * ((recruit.Tier <= 1) ? 1f : ((recruit.Tier <= 3) ? 1.5f : 2f)));
			}

			// Token: 0x06004B2F RID: 19247 RVA: 0x0015AA2E File Offset: 0x00158C2E
			private bool IsTroopTransferable(CharacterObject character, PartyScreenLogic.TroopType type, PartyScreenLogic.PartyRosterSide side, PartyBase leftOwnerParty)
			{
				return this._requestedRecruitCount - this._deliveredRecruitCount >= 0 && (side == PartyScreenLogic.PartyRosterSide.Left || (MobileParty.MainParty.MemberRoster.Contains(character) && character.Occupation == Occupation.Bandit));
			}

			// Token: 0x06004B30 RID: 19248 RVA: 0x0015AA68 File Offset: 0x00158C68
			private bool CheckIfThereIsSuitableRecruitInPlayer()
			{
				bool result = false;
				using (List<TroopRosterElement>.Enumerator enumerator = MobileParty.MainParty.MemberRoster.GetTroopRoster().GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						if (enumerator.Current.Character.Occupation == Occupation.Bandit)
						{
							result = true;
							break;
						}
					}
				}
				return result;
			}

			// Token: 0x06004B31 RID: 19249 RVA: 0x0015AAD4 File Offset: 0x00158CD4
			private void ApplyQuestSuccessConsequences()
			{
				base.AddLog(this.QuestSuccessLog, false);
				TraitLevelingHelper.OnIssueSolvedThroughQuest(base.QuestGiver, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Honor, 30)
				});
				GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, this._rewardGold, false);
				base.QuestGiver.AddPower(10f);
				this.RelationshipChangeWithQuestGiver = 5;
			}

			// Token: 0x06004B32 RID: 19250 RVA: 0x0015AB38 File Offset: 0x00158D38
			protected override void OnBeforeTimedOut(ref bool completeWithSuccess, ref bool doNotResolveTheQuest)
			{
				if (this._deliveredRecruitCount >= this._requestedRecruitCount)
				{
					completeWithSuccess = true;
					this.ApplyQuestSuccessConsequences();
				}
			}

			// Token: 0x06004B33 RID: 19251 RVA: 0x0015AB51 File Offset: 0x00158D51
			protected override void OnTimedOut()
			{
				base.AddLog(this.QuestFailedWithTimeOutLogText, false);
				base.QuestGiver.AddPower(10f);
				this.RelationshipChangeWithQuestGiver = -5;
			}

			// Token: 0x06004B34 RID: 19252 RVA: 0x0015AB79 File Offset: 0x00158D79
			protected override void InitializeQuestOnGameLoad()
			{
				this.SetDialogs();
			}

			// Token: 0x06004B35 RID: 19253 RVA: 0x0015AB81 File Offset: 0x00158D81
			protected override void HourlyTick()
			{
			}

			// Token: 0x04001973 RID: 6515
			private const int QuestGiverRelationBonusOnSuccess = 5;

			// Token: 0x04001974 RID: 6516
			private const int QuestGiverNotablePowerBonusOnSuccess = 10;

			// Token: 0x04001975 RID: 6517
			private const int QuestGiverRelationPenaltyOnFail = -5;

			// Token: 0x04001976 RID: 6518
			private const int NotablePowerPenaltyOnFail = -10;

			// Token: 0x04001977 RID: 6519
			private const int PlayerHonorBonusOnSuccess = 30;

			// Token: 0x04001978 RID: 6520
			[SaveableField(1)]
			private int _requestedRecruitCount;

			// Token: 0x04001979 RID: 6521
			[SaveableField(5)]
			private int _deliveredRecruitCount;

			// Token: 0x0400197A RID: 6522
			[SaveableField(6)]
			private int _rewardGold;

			// Token: 0x0400197B RID: 6523
			[SaveableField(9)]
			private bool _playerReachedRequestedAmount;

			// Token: 0x0400197C RID: 6524
			[SaveableField(7)]
			private JournalLog _questProgressLogTest;
		}

		// Token: 0x0200061E RID: 1566
		public class GangLeaderNeedsRecruitsIssueBehaviorTypeDefiner : SaveableTypeDefiner
		{
			// Token: 0x06004B36 RID: 19254 RVA: 0x0015AB83 File Offset: 0x00158D83
			public GangLeaderNeedsRecruitsIssueBehaviorTypeDefiner() : base(820000)
			{
			}

			// Token: 0x06004B37 RID: 19255 RVA: 0x0015AB90 File Offset: 0x00158D90
			protected override void DefineClassTypes()
			{
				base.AddClassDefinition(typeof(GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssue), 1, null);
				base.AddClassDefinition(typeof(GangLeaderNeedsRecruitsIssueBehavior.GangLeaderNeedsRecruitsIssueQuest), 2, null);
			}
		}
	}
}
